package recharge_management

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type WavepayCreateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// wavepay--新增
func NewWavepayCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WavepayCreateLogic {
	return &WavepayCreateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *WavepayCreateLogic) WavepayCreate(req *types.WavepayCreateRequest) (resp *types.WavepayCreateResponse, err error) {
	rpcReq := rpc.WavepayCreateRequest{
		Code:         req.Code,
		Phone:        req.Phone,
		CardHolder:   req.CardHolder,
		MinAmount:    req.MinAmount,
		MaxAmount:    req.MaxAmount,
		DailyTimes:   req.DailyTimes,
		DailyAmount:  req.DailyAmount,
		RemainTimes:  req.RemainTimes,
		RemainAmount: req.RemainAmount,
		VisionLevel:  req.VisionLevel,
		IsDisplay:    req.IsDisplay,
	}

	rpcResp, err := l.svcCtx.AssetsRpc.TenantChannel.WavepayCreate(l.ctx, &rpcReq)
	if err != nil {
		return nil, err
	}

	return &types.WavepayCreateResponse{
		CommonResp: types.CommonResp{
			Code:    rpcResp.CommonResp.Code,
			Message: rpcResp.CommonResp.Message,
		},
	}, nil
}
